package com.gaeig.base.po;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class PersistenceObject {

  private static final String DEFAULT_USER = "GAEIG";

  @PrimaryKey
  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  private Long id;

  @Persistent
  private Long objectVersion;

  @Persistent
  private String createBy;

  @Persistent
  private Date createDate;

  @Persistent
  private String lastModifyBy;

  @Persistent
  private Date lastModifyDate;

  public PersistenceObject() {
    createBy = DEFAULT_USER;
    lastModifyBy = DEFAULT_USER;
    createDate = new Date();
    lastModifyDate = new Date();
  }

  public Long getId() {
    return id;
  }

  public Long getObjectVersion() {
    return objectVersion;
  }

  public String getCreateBy() {
    return createBy;
  }

  public Date getCreateDate() {
    return createDate;
  }

  public String getLastModifyBy() {
    return lastModifyBy;
  }

  public Date getLastModifyDate() {
    return lastModifyDate;
  }

  public void updateChangeLog() {
    lastModifyDate = new Date();
  }
}
